function [ret,ave_time] = cal_beam_data(index, ns_time, data)
    % 1. hip position
    [ave_dataHP,ave_timeHP] = BeamData(ns_time,data.hippos);
%     ret. ave_dataHP_s(index,:) =ave_dataHP;
%     plot(ave_dataHP); hold on;


    % 2. linearized hip position
    [ave_dataHPL,ave_timeHPL] = BeamData(ns_time,data.delta_hippos);
%     ret.ave_dataHPL_s(index,:) =ave_dataHPL;
%     plot(ave_dataHPL); hold on;


    % 3. non-stance slope
    [ave_dataNSslope,ave_timeNSslope] = BeamData(ns_time,data.nsslope);
%     ret.ave_dataNSslope_s(index,:) =ave_dataNSslope;
%     plot(ave_dataNSslope); hold on;

    % 4. linearized non-stance slope
    [ave_dataNSslopeL,ave_timeNSslopeL] = BeamData(ns_time,data.delta_nsslope);
    ret.ave_dataNSslopeL_s(index,:) =ave_dataNSslopeL; 
%     plot(ave_dataNSslopeL); hold on;

        
    % 5. stance torso slope
    [ave_dataST,ave_timeST] = BeamData(ns_time, data.storso);
    ret.ave_dataST_s(index,:) = ave_dataST;
%     plot(ave_dataST,'r'); hold on;
    
    % 6. Linearized stance torso slope
    [ave_dataSTL,ave_timeSTL] = BeamData(ns_time,data.delta_storso);
    ret.ave_dataSTL_s(index,:) = ave_dataSTL;
%     plot(ave_dataSTL); hold on;
    
    
    % 7. non-stance torso slope
    [ave_dataNST,ave_timeNST] = BeamData(ns_time,data.nstorso);
    ret.ave_dataNST_s(index,:) = ave_dataNST;
    
    
    % 8. linearized non-stance torso slope
    [ave_dataNSTL,ave_timeNSTL] = BeamData(ns_time,data.delta_nstorso);
    ret.ave_dataNSTL_s(index,:) = ave_dataNSTL;
    
    
    % 9. COM
    [ave_dataCOM,ave_timeCOM] = BeamData(ns_time,data.com);
    ret.ave_dataCOM_s(index,:) = ave_dataCOM;
    
    
    % 10. linearized COM
    [ave_dataCOML,ave_timeCOML] = BeamData(ns_time,data.delta_com);
    ret.ave_dataCOML_s(index,:) = ave_dataCOML;
    
    ave_time = ave_timeHP;
end